﻿

using MyFloridaHouse.libSvDTO;
using System.Windows;
using System;
namespace MyFloridaHouse.libSvOpenDistricts.PDF
{
    public class PDFShapeNamePosition
    {
        public double initialCenterX { get; set; }
        public double initialCenterY { get; set; }

        public double centerX { get; set; }
        public double centerY { get; set; }

        public double minX { get; set; }
        public double maxX { get; set; }

        public double minY { get; set; }
        public double maxY { get; set; }

        public PDFPoint centerPoint { get { return new PDFPoint(centerX, centerY); } }

        //bool canFitX;
        //bool canFitY;


        //public Rect shapeRect { get; set; }
        //public Rect clipRect { get; set; }

        //public PDFShapeNamePosition(Rect shapeRect, Rect clipRect, PDFPoint shapeNameCenter, double width, double height)
        public PDFShapeNamePosition(PDFPoint shapeNameCenter, double width, double height)
        {


            this.initialCenterX = shapeNameCenter.x;
            this.initialCenterY = shapeNameCenter.y;

            this.centerX = initialCenterX;
            this.centerY = initialCenterY;

            // center the text on the center point
            this.minX = shapeNameCenter.x;
            this.maxX = shapeNameCenter.x + width;

            this.minY = shapeNameCenter.y;
            this.maxY = shapeNameCenter.y + height;

            
            //this.shapeRect = shapeRect;
            //this.clipRect = clipRect;            
            //bool canFitX = (clipRect.Width - width) > 0 ? true : false ;
            //bool canFitY = (clipRect.Height - height) > 0 ? true : false;

//            MoveInsideClip();
        }

        //public void MoveInsideClip()
        //{
        //    double rightOverflow = clipRect.Right - maxX;
        //    double rightAdjust = rightOverflow < 0 ? rightOverflow  : 0;
            
        //    double leftOverflow = clipRect.Left - minX;
        //    double leftAdjust = leftOverflow < 0 ? 0 : leftOverflow;

        //    double bottomOverflow = clipRect.Bottom - maxY;
        //    double bottomAdjust = bottomOverflow < 0 ? bottomOverflow  : 0;
            
        //    double topOverflow = clipRect.Top - minY;
        //    double topAdjust = topOverflow < 0 ? 0 : topOverflow;

        //    // adjust X
        //        if (leftAdjust > 0)
        //        {
        //            if (rightAdjust < 0)
        //            {
        //                // overlap on left and right
        //                // it can't fit, so leave it alone
        //            }
        //            else
        //            {
        //                // overlap on left only, move to right
        //                if (canFitX)
        //                {
        //                    // it can't fit, move it over to right edge
        //                }
        //                else
        //                {
        //                    // it can fit, move it over all the way
        //                }
        //            }
        //        }
        //        else if (rightAdjust < 0)
        //        {
        //            // overlap on right only
        //        }
        //        else
        //        {
        //            // no overlap at all
        //        }
            

        //    // adjust Y
        //    if (canFitY)
        //    {
        //        if (topAdjust > 0)
        //        {
        //            if (bottomAdjust < 0)
        //            {
        //                // overlap on top and bottom
        //            }
        //            else
        //            {
        //                // overlap on top only
        //            }
        //        }
        //        else if (bottomAdjust < 0)
        //        {
        //            // overlap on bottom only
        //        }
        //    }



        //}


    }
}
